﻿using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Data.SqlClient;

[Serializable()]
public class DbConnection
{

    private string myConnectionString;

    private SqlConnection myConnection;
    public DbConnection(string ConnectionString)
    {
        myConnectionString = ConnectionString;

        GetConnection();

    }

    internal SqlConnection GetConnection()
    {
        if (myConnection == null)
        {
            myConnection = new SqlConnection(myConnectionString);
        }
        if (myConnection.State != ConnectionState.Open)
        {
            myConnection.Open();
        }
        return myConnection;
    }

    internal void CloseConnection()
    {
        if (myConnection.State != ConnectionState.Closed)
        {
            myConnection.Close();
        }
    }

}
